package com.wuxianedu.broadcastreceiver2;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.button_receiver).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction("com.wuxianedu.action.HHXX");//这里action的名称，自定义
                sendBroadcast(intent); //发送无序广播
            }
        });


        findViewById(R.id.button_order_receiver).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /**
                 * sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent,
                 @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver,
                 @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
                 @Nullable Bundle initialExtras);
                 */
                Intent intent = new Intent();
                intent.setAction("com.wuxianedu.action.HAPPY");
                sendOrderedBroadcast(intent, null, new FourthReceiver(), null, Activity.RESULT_OK, "今年十一放七天", null);
            }
        });
    }
}
